import 'package:check_app/api/request.dart';
import 'package:check_app/navigate/navigate.dart';
import 'package:check_app/page/LoginPage.dart';
import 'package:check_app/scoped_model/app_model.dart';
import 'package:check_app/util/pref_util.dart';
import 'package:check_app/widgets/UpdaterPage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:getuiflut/getuiflut.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await FlutterDownloader.initialize();
  // Request().setProxy();
  bool isLogin = await PrefUtil().isLogin();
  runApp(MyApp(isLogin: isLogin));
}

class MyApp extends StatelessWidget {
  final bool isLogin;
  GlobalModel globalModel = GlobalModel();
  MyApp({this.isLogin});
  @override
  Widget build(BuildContext context) {
    Getuiflut.initGetuiSdk;
    return ScopedModel<GlobalModel>(
      model: globalModel,
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        // home: Navigete(),
        home: UpdaterPage(
          isLogin ? Navigete() : LoginPage(),
        ),
      ),
    );
  }
}
